package com.solution.action;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.solution.form.ReportForm;


public class ReportAction extends Action {
	Logger logger = Logger.getLogger(ReportAction.class.getName());
	public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request, 
			HttpServletResponse response)throws IOException, ServletException{
		request.setAttribute("tab", "REPORT");
		ReportForm reportForm = (ReportForm)form;
		if("/enrollmentReport".equals(mapping.getPath())){
			return enrollmentReport(mapping, reportForm, request, response);
		}else if("/examwiseReport".equals(mapping.getPath())){
			return  mapping.findForward("examwiseReport");
		}else if("/questionwiseReport".equals(mapping.getPath())){
			return  mapping.findForward("questionwiseReport");
		}		
		return mapping.findForward("success");
	}
	
	
	private ActionForward enrollmentReport(ActionMapping mapping,ReportForm reportForm,
			HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
		try {
			//reportForm.setStoreList(getStoreList());
			return mapping.findForward("success");
		}catch (Exception e) {
			logger.error(e, e);
			return mapping.findForward("error");
		}
	}
	
	

}
